package com.xyoto.takeawayUser.controller;

import com.xyoto.takeawayUser.service.HomeService;
import com.xyoto.takeawayUser.service.ShopService;
import com.xyoto.takeawayUser.utils.PageUtils;
import com.xyoto.takeawayUser.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("/home")
@Api(tags = "首页")
public class HomeController {

    @Autowired
    private HomeService homeService;
    @Autowired
    private ShopService shopService;

    @ApiOperation("分页查询所有店铺列表")
    @GetMapping("/home/getAllShops")
    private Result getAllShops(@Valid PageUtils pageDTO){
        return shopService.getAllShops(pageDTO);
    }

    @GetMapping("/getShoppingInfo")
    @ApiOperation("获取商品详情")
    public Result getShoppingInfo(
                @NotNull(message = "商品id不能为空")
                @RequestParam(value = "shoppingId",defaultValue = "1") Integer shoppingId){
        return homeService.getShoppingInfo(shoppingId);
    }

}
